import {NavigationGuardNext, RouteLocationNormalized} from "vue-router";
import {message} from "ant-design-vue";

export default (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {
    //检测是否具有权限
    if (!to.meta.noAuth && !sessionStorage.getItem('token') && from) {
        next('/login')
        message.error('缺少凭证，请重新登录')
    } else {
        if (to.matched.length === 0) {
            next('/404')
        } else {
            next()
        }
    }
}